//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<import_dx9.h>
///	@path	~/src/graphics/dx9/
///	@date	2008/09/16
///	@brief	.

#pragma once

#include "xeres.h"

// DirectX 9 header
#define D3D_DISABLE_9EX 1
#include <d3d9.h>
#include <d3dx9.h>

namespace xeres {

	namespace dx9
	{
		/// \brief Explicit initialize Direct3D 9.
		void InitializeDirect3D9( bool enableDebug = false , bool enablePerf = false );

		/// \name D3D9 API port.
		//@{
		IDirect3D9 * WINAPI Direct3DCreate9(UINT SDKVersion);

		int WINAPI D3DPERF_BeginEvent( D3DCOLOR col, LPCWSTR wszName );
		int WINAPI D3DPERF_EndEvent( void );
		void WINAPI D3DPERF_SetMarker( D3DCOLOR col, LPCWSTR wszName );
		void WINAPI D3DPERF_SetRegion( D3DCOLOR col, LPCWSTR wszName );
		BOOL WINAPI D3DPERF_QueryRepeatFrame( void );

		void WINAPI D3DPERF_SetOptions( DWORD dwOptions );
		DWORD WINAPI D3DPERF_GetStatus( void );
		//@}

		/// \brief	Explicit initialize Direct3D X 9 with specific version.
		void InitializeDirect3DX9( bool enableDebug = false , uint version = 40 );
		
		/// \name D3DX 9 API port.
		//@{

		// Converts an array 32-bit floats to 16-bit floats
		D3DXFLOAT16* WINAPI D3DXFloat32To16Array( D3DXFLOAT16 *pOut, CONST FLOAT *pIn, UINT n );
		// Converts an array 16-bit floats to 32-bit floats
		FLOAT* WINAPI D3DXFloat16To32Array( FLOAT *pOut, CONST D3DXFLOAT16 *pIn, UINT n );


		D3DXVECTOR2* WINAPI D3DXVec2Normalize
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV );

		// Hermite interpolation between position V1, tangent T1 (when s == 0)
		// and position V2, tangent T2 (when s == 1).
		D3DXVECTOR2* WINAPI D3DXVec2Hermite
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1,
			CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s );

		// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
		D3DXVECTOR2* WINAPI D3DXVec2CatmullRom
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1,
			CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s );

		// Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
		D3DXVECTOR2* WINAPI D3DXVec2BaryCentric
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2,
			CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g);

		// Transform (x, y, 0, 1) by matrix.
		D3DXVECTOR4* WINAPI D3DXVec2Transform
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );

		// Transform (x, y, 0, 1) by matrix, project result back into w=1.
		D3DXVECTOR2* WINAPI D3DXVec2TransformCoord
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );

		// Transform (x, y, 0, 0) by matrix.
		D3DXVECTOR2* WINAPI D3DXVec2TransformNormal
			( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM );

		// Transform Array (x, y, 0, 1) by matrix.
		D3DXVECTOR4* WINAPI D3DXVec2TransformArray
			( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n);

		// Transform Array (x, y, 0, 1) by matrix, project result back into w=1.
		D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray
			( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );

		// Transform Array (x, y, 0, 0) by matrix.
		D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray
			( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );


		D3DXVECTOR3* WINAPI D3DXVec3Normalize
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV );

		// Hermite interpolation between position V1, tangent T1 (when s == 0)
		// and position V2, tangent T2 (when s == 1).
		D3DXVECTOR3* WINAPI D3DXVec3Hermite
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1,
			CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s );

		// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
		D3DXVECTOR3* WINAPI D3DXVec3CatmullRom
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1,
			CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s );

		// Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
		D3DXVECTOR3* WINAPI D3DXVec3BaryCentric
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
			CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g);

		// Transform (x, y, z, 1) by matrix.
		D3DXVECTOR4* WINAPI D3DXVec3Transform
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );

		// Transform (x, y, z, 1) by matrix, project result back into w=1.
		D3DXVECTOR3* WINAPI D3DXVec3TransformCoord
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );

		// Transform (x, y, z, 0) by matrix.  If you transforming a normal by a 
		// non-affine matrix, the matrix you pass to this function should be the 
		// transpose of the inverse of the matrix you would use to transform a coord.
		D3DXVECTOR3* WINAPI D3DXVec3TransformNormal
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM );


		// Transform Array (x, y, z, 1) by matrix. 
		D3DXVECTOR4* WINAPI D3DXVec3TransformArray
			( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );

		// Transform Array (x, y, z, 1) by matrix, project result back into w=1.
		D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray
			( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );

		// Transform (x, y, z, 0) by matrix.  If you transforming a normal by a 
		// non-affine matrix, the matrix you pass to this function should be the 
		// transpose of the inverse of the matrix you would use to transform a coord.
		D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray
			( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );

		// Project vector from object space into screen space
		D3DXVECTOR3* WINAPI D3DXVec3Project
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport,
			CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld);

		// Project vector from screen space into object space
		D3DXVECTOR3* WINAPI D3DXVec3Unproject
			( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport,
			CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld);

		// Project vector Array from object space into screen space
		D3DXVECTOR3* WINAPI D3DXVec3ProjectArray
			( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport,
			CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n);

		// Project vector Array from screen space into object space
		D3DXVECTOR3* WINAPI D3DXVec3UnprojectArray
			( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DVIEWPORT9 *pViewport,
			CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld, UINT n);



		// Cross-product in 4 dimensions.
		D3DXVECTOR4* WINAPI D3DXVec4Cross
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
			CONST D3DXVECTOR4 *pV3);

		D3DXVECTOR4* WINAPI D3DXVec4Normalize
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV );

		// Hermite interpolation between position V1, tangent T1 (when s == 0)
		// and position V2, tangent T2 (when s == 1).
		D3DXVECTOR4* WINAPI D3DXVec4Hermite
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1,
			CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s );

		// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
		D3DXVECTOR4* WINAPI D3DXVec4CatmullRom
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1,
			CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s );

		// Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
		D3DXVECTOR4* WINAPI D3DXVec4BaryCentric
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2,
			CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g);

		// Transform vector by matrix.
		D3DXVECTOR4* WINAPI D3DXVec4Transform
			( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM );

		// Transform vector array by matrix.
		D3DXVECTOR4* WINAPI D3DXVec4TransformArray
			( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n );


		FLOAT WINAPI D3DXMatrixDeterminant
			( CONST D3DXMATRIX *pM );

		HRESULT WINAPI D3DXMatrixDecompose
			( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, 
			D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM );

		D3DXMATRIX* WINAPI D3DXMatrixTranspose
			( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM );

		// Matrix multiplication.  The result represents the transformation M2
		// followed by the transformation M1.  (Out = M1 * M2)
		D3DXMATRIX* WINAPI D3DXMatrixMultiply
			( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );

		// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
		D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose
			( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 );

		// Calculate inverse of matrix.  Inversion my fail, in which case NULL will
		// be returned.  The determinant of pM is also returned it pfDeterminant
		// is non-NULL.
		D3DXMATRIX* WINAPI D3DXMatrixInverse
			( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM );

		// Build a matrix which scales by (sx, sy, sz)
		D3DXMATRIX* WINAPI D3DXMatrixScaling
			( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz );

		// Build a matrix which translates by (x, y, z)
		D3DXMATRIX* WINAPI D3DXMatrixTranslation
			( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z );

		// Build a matrix which rotates around the X axis
		D3DXMATRIX* WINAPI D3DXMatrixRotationX
			( D3DXMATRIX *pOut, FLOAT Angle );

		// Build a matrix which rotates around the Y axis
		D3DXMATRIX* WINAPI D3DXMatrixRotationY
			( D3DXMATRIX *pOut, FLOAT Angle );

		// Build a matrix which rotates around the Z axis
		D3DXMATRIX* WINAPI D3DXMatrixRotationZ
			( D3DXMATRIX *pOut, FLOAT Angle );

		// Build a matrix which rotates around an arbitrary axis
		D3DXMATRIX* WINAPI D3DXMatrixRotationAxis
			( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );

		// Build a matrix from a quaternion
		D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion
			( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ);

		// Yaw around the Y axis, a pitch around the X axis,
		// and a roll around the Z axis.
		D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll
			( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );

		// Build transformation matrix.  NULL arguments are treated as identity.
		// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
		D3DXMATRIX* WINAPI D3DXMatrixTransformation
			( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter,
			CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling,
			CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation,
			CONST D3DXVECTOR3 *pTranslation);

		// Build 2D transformation matrix in XY plane.  NULL arguments are treated as identity.
		// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
		D3DXMATRIX* WINAPI D3DXMatrixTransformation2D
			( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, 
			FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, 
			CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, 
			CONST D3DXVECTOR2* pTranslation);

		// Build affine transformation matrix.  NULL arguments are treated as identity.
		// Mout = Ms * Mrc-1 * Mr * Mrc * Mt
		D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation
			( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter,
			CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation);

		// Build 2D affine transformation matrix in XY plane.  NULL arguments are treated as identity.
		// Mout = Ms * Mrc-1 * Mr * Mrc * Mt
		D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D
			( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, 
			FLOAT Rotation, CONST D3DXVECTOR2* pTranslation);

		// Build a lookat matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixLookAtRH
			( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
			CONST D3DXVECTOR3 *pUp );

		// Build a lookat matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixLookAtLH
			( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt,
			CONST D3DXVECTOR3 *pUp );

		// Build a perspective projection matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH
			( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

		// Build a perspective projection matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH
			( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

		// Build a perspective projection matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH
			( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );

		// Build a perspective projection matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH
			( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );

		// Build a perspective projection matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH
			( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
			FLOAT zf );

		// Build a perspective projection matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH
			( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
			FLOAT zf );

		// Build an ortho projection matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixOrthoRH
			( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

		// Build an ortho projection matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixOrthoLH
			( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

		// Build an ortho projection matrix. (right-handed)
		D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH
			( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
			FLOAT zf );

		// Build an ortho projection matrix. (left-handed)
		D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH
			( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
			FLOAT zf );

		// Build a matrix which flattens geometry into a plane, as if casting
		// a shadow from a light.
		D3DXMATRIX* WINAPI D3DXMatrixShadow
			( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight,
			CONST D3DXPLANE *pPlane );

		// Build a matrix which reflects the coordinate system about a plane
		D3DXMATRIX* WINAPI D3DXMatrixReflect
			( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane );


		// Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
		void WINAPI D3DXQuaternionToAxisAngle
			( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle );

		// Build a quaternion from a rotation matrix.
		D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix
			( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM);

		// Rotation about arbitrary axis.
		D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis
			( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle );

		// Yaw around the Y axis, a pitch around the X axis,
		// and a roll around the Z axis.
		D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll
			( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );

		// Quaternion multiplication.  The result represents the rotation Q2
		// followed by the rotation Q1.  (Out = Q2 * Q1)
		D3DXQUATERNION* WINAPI D3DXQuaternionMultiply
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
			CONST D3DXQUATERNION *pQ2 );

		D3DXQUATERNION* WINAPI D3DXQuaternionNormalize
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );

		// Conjugate and re-norm
		D3DXQUATERNION* WINAPI D3DXQuaternionInverse
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );

		// Expects unit quaternions.
		// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
		D3DXQUATERNION* WINAPI D3DXQuaternionLn
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );

		// Expects pure quaternions. (w == 0)  w is ignored in calculation.
		// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
		D3DXQUATERNION* WINAPI D3DXQuaternionExp
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ );

		// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1).
		// Expects unit quaternions.
		D3DXQUATERNION* WINAPI D3DXQuaternionSlerp
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
			CONST D3DXQUATERNION *pQ2, FLOAT t );

		// Spherical quadrangle interpolation.
		// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
		D3DXQUATERNION* WINAPI D3DXQuaternionSquad
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
			CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB,
			CONST D3DXQUATERNION *pC, FLOAT t );

		// Setup control points for spherical quadrangle interpolation
		// from Q1 to Q2.  The control points are chosen in such a way 
		// to ensure the continuity of tangents with adjacent segments.
		void WINAPI D3DXQuaternionSquadSetup
			( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut,
			CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, 
			CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 );

		// Barycentric interpolation.
		// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
		D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric
			( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1,
			CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3,
			FLOAT f, FLOAT g );



		// Normalize plane (so that |a,b,c| == 1)
		D3DXPLANE* WINAPI D3DXPlaneNormalize
			( D3DXPLANE *pOut, CONST D3DXPLANE *pP);

		// Find the intersection between a plane and a line.  If the line is
		// parallel to the plane, NULL is returned.
		D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine
			( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1,
			CONST D3DXVECTOR3 *pV2);

		// Construct a plane from a point and a normal
		D3DXPLANE* WINAPI D3DXPlaneFromPointNormal
			( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal);

		// Construct a plane from 3 points
		D3DXPLANE* WINAPI D3DXPlaneFromPoints
			( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2,
			CONST D3DXVECTOR3 *pV3);

		// Transform a plane by a matrix.  The vector (a,b,c) must be normal.
		// M should be the inverse transpose of the transformation desired.
		D3DXPLANE* WINAPI D3DXPlaneTransform
			( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM );

		// Transform an array of planes by a matrix.  The vectors (a,b,c) must be normal.
		// M should be the inverse transpose of the transformation desired.
		D3DXPLANE* WINAPI D3DXPlaneTransformArray
			( D3DXPLANE *pOut, UINT OutStride, CONST D3DXPLANE *pP, UINT PStride, CONST D3DXMATRIX *pM, UINT n );



		
		// Interpolate r,g,b between desaturated color and color.
		// DesaturatedColor + s(Color - DesaturatedColor)
		D3DXCOLOR* WINAPI D3DXColorAdjustSaturation
			(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s);

		// Interpolate r,g,b between 50% grey and color.  Grey + s(Color - Grey)
		D3DXCOLOR* WINAPI D3DXColorAdjustContrast
			(D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c);



		// Calculate Fresnel term given the cosine of theta (likely obtained by
		// taking the dot of two normals), and the refraction index of the material.
		FLOAT WINAPI D3DXFresnelTerm
			(FLOAT CosTheta, FLOAT RefractionIndex);


		HRESULT WINAPI D3DXCreateMatrixStack( 
			DWORD               Flags, 
			LPD3DXMATRIXSTACK*  ppStack);


		FLOAT* WINAPI D3DXSHEvalDirection
			(  FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir );

		FLOAT* WINAPI D3DXSHRotate
			( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn );


		FLOAT* WINAPI D3DXSHRotateZ
			( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn );

		FLOAT* WINAPI D3DXSHAdd
			( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB );

		FLOAT* WINAPI D3DXSHScale
			( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale );

		FLOAT WINAPI D3DXSHDot
			( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB );

		FLOAT* WINAPI D3DXSHMultiply2( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG);
		FLOAT* WINAPI D3DXSHMultiply3( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG);
		FLOAT* WINAPI D3DXSHMultiply4( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG);
		FLOAT* WINAPI D3DXSHMultiply5( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG);
		FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG);

		HRESULT WINAPI D3DXSHEvalDirectionalLight
			( UINT Order, CONST D3DXVECTOR3 *pDir, 
			FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
			FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

		HRESULT WINAPI D3DXSHEvalSphericalLight
			( UINT Order, CONST D3DXVECTOR3 *pPos, FLOAT Radius,
			FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
			FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

		HRESULT WINAPI D3DXSHEvalConeLight
			( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius,
			FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
			FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

		HRESULT WINAPI D3DXSHEvalHemisphereLight
			( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom,
			FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

		HRESULT WINAPI D3DXSHProjectCubeMap
			( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap,
			FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );


		HRESULT WINAPI D3DXCreateSprite( 
			LPDIRECT3DDEVICE9   pDevice, 
			LPD3DXSPRITE*       ppSprite);


		HRESULT WINAPI 
			D3DXCreateFont(
			LPDIRECT3DDEVICE9       pDevice,  
			INT                     Height,
			UINT                    Width,
			UINT                    Weight,
			UINT                    MipLevels,
			BOOL                    Italic,
			DWORD                   CharSet,
			DWORD                   OutputPrecision,
			DWORD                   Quality,
			DWORD                   PitchAndFamily,
			LPCWSTR                 pFaceName,
			LPD3DXFONT*             ppFont);

		HRESULT WINAPI 
			D3DXCreateFontIndirect( 
			LPDIRECT3DDEVICE9       pDevice, 
			CONST D3DXFONT_DESC*   pDesc, 
			LPD3DXFONT*             ppFont);

		HRESULT WINAPI
			D3DXCreateRenderToSurface(
			LPDIRECT3DDEVICE9       pDevice,
			UINT                    Width,
			UINT                    Height,
			D3DFORMAT               Format,
			BOOL                    DepthStencil,
			D3DFORMAT               DepthStencilFormat,
			LPD3DXRENDERTOSURFACE*  ppRenderToSurface);

		HRESULT WINAPI
			D3DXCreateRenderToEnvMap(
			LPDIRECT3DDEVICE9       pDevice,
			UINT                    Size,
			UINT                    MipLevels,
			D3DFORMAT               Format,
			BOOL                    DepthStencil,
			D3DFORMAT               DepthStencilFormat,
			LPD3DXRenderToEnvMap*   ppRenderToEnvMap);

		HRESULT WINAPI
			D3DXCreateLine(
			LPDIRECT3DDEVICE9   pDevice,
			LPD3DXLINE*         ppLine);

		HRESULT WINAPI
			D3DXAssembleShaderFromFile(
			LPCWSTR                         pSrcFile,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs);

		HRESULT WINAPI
			D3DXAssembleShader(
			LPCSTR                          pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs);

		HRESULT WINAPI
			D3DXCompileShaderFromFile(
			LPCWSTR                         pSrcFile,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			LPCSTR                          pFunctionName,
			LPCSTR                          pProfile,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs,
			LPD3DXCONSTANTTABLE*            ppConstantTable);

		HRESULT WINAPI
			D3DXCompileShader(
			LPCSTR                          pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			LPCSTR                          pFunctionName,
			LPCSTR                          pProfile,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs,
			LPD3DXCONSTANTTABLE*            ppConstantTable);

		HRESULT WINAPI
			D3DXDisassembleShader(
			CONST DWORD*                    pShader, 
			BOOL                            EnableColorCode, 
			LPCSTR                          pComments, 
			LPD3DXBUFFER*                   ppDisassembly);

		LPCSTR WINAPI
			D3DXGetPixelShaderProfile(
			LPDIRECT3DDEVICE9               pDevice);

		LPCSTR WINAPI
			D3DXGetVertexShaderProfile(
			LPDIRECT3DDEVICE9               pDevice);

		HRESULT WINAPI
			D3DXFindShaderComment(
			CONST DWORD*                    pFunction,
			DWORD                           FourCC,
			LPCVOID*                        ppData,
			UINT*                           pSizeInBytes);

		UINT WINAPI
			D3DXGetShaderSize(
			CONST DWORD*                    pFunction);

		DWORD WINAPI
			D3DXGetShaderVersion(
			CONST DWORD*                    pFunction);

		HRESULT WINAPI
			D3DXGetShaderInputSemantics(
			CONST DWORD*                    pFunction,
			D3DXSEMANTIC*                   pSemantics,
			UINT*                           pCount);

		HRESULT WINAPI
			D3DXGetShaderOutputSemantics(
			CONST DWORD*                    pFunction,
			D3DXSEMANTIC*                   pSemantics,
			UINT*                           pCount);

		HRESULT WINAPI
			D3DXGetShaderSamplers(
			CONST DWORD*                    pFunction,
			LPCSTR*                         pSamplers,
			UINT*                           pCount);

		HRESULT WINAPI
			D3DXGetShaderConstantTable(
			CONST DWORD*                    pFunction,
			LPD3DXCONSTANTTABLE*            ppConstantTable);

		HRESULT WINAPI
			D3DXGetShaderConstantTableEx(
			CONST DWORD*                    pFunction,
			DWORD                           Flags,
			LPD3DXCONSTANTTABLE*            ppConstantTable);

		HRESULT WINAPI
			D3DXCreateTextureShader(
			CONST DWORD*                    pFunction, 
			LPD3DXTEXTURESHADER*            ppTextureShader);

		HRESULT WINAPI
			D3DXGatherFragmentsFromFile(
			LPCWSTR                         pSrcFile,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs);

		HRESULT WINAPI
			D3DXGatherFragments(
			LPCSTR                          pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXBUFFER*                   ppShader,
			LPD3DXBUFFER*                   ppErrorMsgs);

		HRESULT WINAPI
			D3DXCreateFragmentLinker(
			LPDIRECT3DDEVICE9               pDevice,
			UINT                            ShaderCacheSize,
			LPD3DXFRAGMENTLINKER*           ppFragmentLinker);

		HRESULT WINAPI
			D3DXCreateFragmentLinkerEx(
			LPDIRECT3DDEVICE9               pDevice,
			UINT                            ShaderCacheSize,
			DWORD                           Flags,
			LPD3DXFRAGMENTLINKER*           ppFragmentLinker);

		HRESULT WINAPI 
			D3DXPreprocessShaderFromFile(
			LPCWSTR                      pSrcFile,
			CONST D3DXMACRO*             pDefines,
			LPD3DXINCLUDE                pInclude,
			LPD3DXBUFFER*                ppShaderText,
			LPD3DXBUFFER*                ppErrorMsgs);

		HRESULT WINAPI 
			D3DXPreprocessShader(
			LPCSTR                       pSrcData,
			UINT                         SrcDataSize,
			CONST D3DXMACRO*             pDefines,
			LPD3DXINCLUDE                pInclude,
			LPD3DXBUFFER*                ppShaderText,
			LPD3DXBUFFER*                ppErrorMsgs);

		
		HRESULT WINAPI
			D3DXCreateEffectPool(
			LPD3DXEFFECTPOOL*               ppPool);

		HRESULT WINAPI
			D3DXCreateEffectFromFile(
			LPDIRECT3DDEVICE9               pDevice,
			LPCWSTR                         pSrcFile,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXEFFECTPOOL                pPool,
			LPD3DXEFFECT*                   ppEffect,
			LPD3DXBUFFER*                   ppCompilationErrors);

		HRESULT WINAPI
			D3DXCreateEffect(
			LPDIRECT3DDEVICE9               pDevice,
			LPCVOID                         pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXEFFECTPOOL                pPool,
			LPD3DXEFFECT*                   ppEffect,
			LPD3DXBUFFER*                   ppCompilationErrors);

		HRESULT WINAPI
			D3DXCreateEffectFromFileEx(
				LPDIRECT3DDEVICE9               pDevice,
				LPCWSTR                         pSrcFile,
				CONST D3DXMACRO*                pDefines,
				LPD3DXINCLUDE                   pInclude,
				LPCSTR                          pSkipConstants, 
				DWORD                           Flags,
				LPD3DXEFFECTPOOL                pPool,
				LPD3DXEFFECT*                   ppEffect,
				LPD3DXBUFFER*                   ppCompilationErrors);

		HRESULT WINAPI
			D3DXCreateEffectEx(
			LPDIRECT3DDEVICE9               pDevice,
			LPCVOID                         pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			LPCSTR                          pSkipConstants, 
			DWORD                           Flags,
			LPD3DXEFFECTPOOL                pPool,
			LPD3DXEFFECT*                   ppEffect,
			LPD3DXBUFFER*                   ppCompilationErrors);

		HRESULT WINAPI
			D3DXCreateEffectCompilerFromFile(
				LPCWSTR                         pSrcFile,
				CONST D3DXMACRO*                pDefines,
				LPD3DXINCLUDE                   pInclude,
				DWORD                           Flags,
				LPD3DXEFFECTCOMPILER*           ppCompiler,
				LPD3DXBUFFER*                   ppParseErrors);

		HRESULT WINAPI
			D3DXCreateEffectCompiler(
			LPCSTR                          pSrcData,
			UINT                            SrcDataLen,
			CONST D3DXMACRO*                pDefines,
			LPD3DXINCLUDE                   pInclude,
			DWORD                           Flags,
			LPD3DXEFFECTCOMPILER*           ppCompiler,
			LPD3DXBUFFER*                   ppParseErrors);

		HRESULT WINAPI 
			D3DXDisassembleEffect(
			LPD3DXEFFECT pEffect, 
			BOOL EnableColorCode, 
			LPD3DXBUFFER *ppDisassembly);
        
		HRESULT WINAPI
			D3DXGetImageInfoFromFile(
			LPCWSTR                   pSrcFile,
			D3DXIMAGE_INFO*           pSrcInfo);

		HRESULT WINAPI
			D3DXGetImageInfoFromFileInMemory(
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			D3DXIMAGE_INFO*           pSrcInfo);


		HRESULT WINAPI
			D3DXLoadSurfaceFromFile(
			LPDIRECT3DSURFACE9        pDestSurface,
			CONST PALETTEENTRY*       pDestPalette,
			CONST RECT*               pDestRect,
			LPCWSTR                   pSrcFile,
			CONST RECT*               pSrcRect,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo);

		HRESULT WINAPI
			D3DXLoadSurfaceFromFileInMemory(
			LPDIRECT3DSURFACE9        pDestSurface,
			CONST PALETTEENTRY*       pDestPalette,
			CONST RECT*               pDestRect,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			CONST RECT*               pSrcRect,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo);

		HRESULT WINAPI
			D3DXLoadSurfaceFromSurface(
			LPDIRECT3DSURFACE9        pDestSurface,
			CONST PALETTEENTRY*       pDestPalette,
			CONST RECT*               pDestRect,
			LPDIRECT3DSURFACE9        pSrcSurface,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST RECT*               pSrcRect,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey);


		HRESULT WINAPI
			D3DXLoadSurfaceFromMemory(
			LPDIRECT3DSURFACE9        pDestSurface,
			CONST PALETTEENTRY*       pDestPalette,
			CONST RECT*               pDestRect,
			LPCVOID                   pSrcMemory,
			D3DFORMAT                 SrcFormat,
			UINT                      SrcPitch,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST RECT*               pSrcRect,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey);

		HRESULT WINAPI
			D3DXSaveSurfaceToFile(
			LPCWSTR                   pDestFile,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DSURFACE9        pSrcSurface,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST RECT*               pSrcRect);

		HRESULT WINAPI
			D3DXSaveSurfaceToFileInMemory(
			LPD3DXBUFFER*             ppDestBuf,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DSURFACE9        pSrcSurface,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST RECT*               pSrcRect);

		HRESULT WINAPI
			D3DXLoadVolumeFromFile(
			LPDIRECT3DVOLUME9         pDestVolume,
			CONST PALETTEENTRY*       pDestPalette,
			CONST D3DBOX*             pDestBox,
			LPCWSTR                   pSrcFile,
			CONST D3DBOX*             pSrcBox,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo);

		HRESULT WINAPI
			D3DXLoadVolumeFromFileInMemory(
			LPDIRECT3DVOLUME9         pDestVolume,
			CONST PALETTEENTRY*       pDestPalette,
			CONST D3DBOX*             pDestBox,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			CONST D3DBOX*             pSrcBox,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo);

		HRESULT WINAPI
			D3DXLoadVolumeFromVolume(
			LPDIRECT3DVOLUME9         pDestVolume,
			CONST PALETTEENTRY*       pDestPalette,
			CONST D3DBOX*             pDestBox,
			LPDIRECT3DVOLUME9         pSrcVolume,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST D3DBOX*             pSrcBox,
			DWORD                     Filter,
			D3DCOLOR                  ColorKey);

		HRESULT WINAPI
			D3DXSaveVolumeToFile(
			LPCWSTR                   pDestFile,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DVOLUME9         pSrcVolume,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST D3DBOX*             pSrcBox);

		HRESULT WINAPI
			D3DXSaveVolumeToFileInMemory(
			LPD3DXBUFFER*             ppDestBuf,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DVOLUME9         pSrcVolume,
			CONST PALETTEENTRY*       pSrcPalette,
			CONST D3DBOX*             pSrcBox);

		HRESULT WINAPI
			D3DXCheckTextureRequirements(
			LPDIRECT3DDEVICE9         pDevice,
			UINT*                     pWidth,
			UINT*                     pHeight,
			UINT*                     pNumMipLevels,
			DWORD                     Usage,
			D3DFORMAT*                pFormat,
			D3DPOOL                   Pool);

		HRESULT WINAPI
			D3DXCheckCubeTextureRequirements(
			LPDIRECT3DDEVICE9         pDevice,
			UINT*                     pSize,
			UINT*                     pNumMipLevels,
			DWORD                     Usage,
			D3DFORMAT*                pFormat,
			D3DPOOL                   Pool);

		HRESULT WINAPI
			D3DXCheckVolumeTextureRequirements(
			LPDIRECT3DDEVICE9         pDevice,
			UINT*                     pWidth,
			UINT*                     pHeight,
			UINT*                     pDepth,
			UINT*                     pNumMipLevels,
			DWORD                     Usage,
			D3DFORMAT*                pFormat,
			D3DPOOL                   Pool);

		HRESULT WINAPI
			D3DXCreateTexture(
			LPDIRECT3DDEVICE9         pDevice,
			UINT                      Width,
			UINT                      Height,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			LPDIRECT3DTEXTURE9*       ppTexture);

		HRESULT WINAPI
			D3DXCreateCubeTexture(
			LPDIRECT3DDEVICE9         pDevice,
			UINT                      Size,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			LPDIRECT3DCUBETEXTURE9*   ppCubeTexture);

		HRESULT WINAPI
			D3DXCreateVolumeTexture(
			LPDIRECT3DDEVICE9         pDevice,
			UINT                      Width,
			UINT                      Height,
			UINT                      Depth,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);

		HRESULT WINAPI
			D3DXCreateTextureFromFile(
			LPDIRECT3DDEVICE9         pDevice,
			LPCWSTR                   pSrcFile,
			LPDIRECT3DTEXTURE9*       ppTexture);

		HRESULT WINAPI
			D3DXCreateTextureFromFileInMemory(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			LPDIRECT3DTEXTURE9*       ppTexture);

		HRESULT WINAPI
			D3DXCreateCubeTextureFromFile(
			LPDIRECT3DDEVICE9         pDevice,
			LPCWSTR                   pSrcFile,
			LPDIRECT3DCUBETEXTURE9*   ppCubeTexture);

		HRESULT WINAPI
			D3DXCreateCubeTextureFromFileInMemory(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			LPDIRECT3DCUBETEXTURE9*   ppCubeTexture);

		HRESULT WINAPI
			D3DXCreateVolumeTextureFromFile(
			LPDIRECT3DDEVICE9         pDevice,
			LPCWSTR                   pSrcFile,
			LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);

		HRESULT WINAPI
			D3DXCreateVolumeTextureFromFileInMemory(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);


		// FromFileInMemoryEx

		HRESULT WINAPI
			D3DXCreateTextureFromFileEx(
			LPDIRECT3DDEVICE9         pDevice,
			LPCWSTR                   pSrcFile,
			UINT                      Width,
			UINT                      Height,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			DWORD                     Filter,
			DWORD                     MipFilter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo,
			PALETTEENTRY*             pPalette,
			LPDIRECT3DTEXTURE9*       ppTexture);

		HRESULT WINAPI
			D3DXCreateTextureFromFileInMemoryEx(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			UINT                      Width,
			UINT                      Height,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			DWORD                     Filter,
			DWORD                     MipFilter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo,
			PALETTEENTRY*             pPalette,
			LPDIRECT3DTEXTURE9*       ppTexture);

		HRESULT WINAPI
			D3DXCreateCubeTextureFromFileEx(
			LPDIRECT3DDEVICE9 pDevice,
			LPCTSTR pSrcFile,
			UINT Width,
			UINT Height,
			UINT MipLevels,
			DWORD Usage,
			D3DFORMAT Format,
			D3DPOOL Pool,
			DWORD Filter,
			DWORD MipFilter,
			D3DCOLOR ColorKey,
			D3DXIMAGE_INFO * pSrcInfo,
			PALETTEENTRY * pPalette,
			LPDIRECT3DTEXTURE9 * ppTexture
			);

		HRESULT WINAPI
			D3DXCreateCubeTextureFromFileInMemoryEx(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			UINT                      Size,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			DWORD                     Filter,
			DWORD                     MipFilter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo,
			PALETTEENTRY*             pPalette,
			LPDIRECT3DCUBETEXTURE9*   ppCubeTexture);

		HRESULT WINAPI
			D3DXCreateVolumeTextureFromFileEx(
			LPDIRECT3DDEVICE9         pDevice,
			LPCWSTR                   pSrcFile,
			UINT                      Width,
			UINT                      Height,
			UINT                      Depth,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			DWORD                     Filter,
			DWORD                     MipFilter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo,
			PALETTEENTRY*             pPalette,
			LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);

		HRESULT WINAPI
			D3DXCreateVolumeTextureFromFileInMemoryEx(
			LPDIRECT3DDEVICE9         pDevice,
			LPCVOID                   pSrcData,
			UINT                      SrcDataSize,
			UINT                      Width,
			UINT                      Height,
			UINT                      Depth,
			UINT                      MipLevels,
			DWORD                     Usage,
			D3DFORMAT                 Format,
			D3DPOOL                   Pool,
			DWORD                     Filter,
			DWORD                     MipFilter,
			D3DCOLOR                  ColorKey,
			D3DXIMAGE_INFO*           pSrcInfo,
			PALETTEENTRY*             pPalette,
			LPDIRECT3DVOLUMETEXTURE9* ppVolumeTexture);

		HRESULT WINAPI
			D3DXSaveTextureToFile(
			LPCWSTR                   pDestFile,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DBASETEXTURE9    pSrcTexture,
			CONST PALETTEENTRY*       pSrcPalette);

		HRESULT WINAPI
			D3DXSaveTextureToFileInMemory(
			LPD3DXBUFFER*             ppDestBuf,
			D3DXIMAGE_FILEFORMAT      DestFormat,
			LPDIRECT3DBASETEXTURE9    pSrcTexture,
			CONST PALETTEENTRY*       pSrcPalette);

		HRESULT WINAPI
			D3DXFilterTexture(
			LPDIRECT3DBASETEXTURE9    pBaseTexture,
			CONST PALETTEENTRY*       pPalette,
			UINT                      SrcLevel,
			DWORD                     Filter);

		HRESULT WINAPI
			D3DXFillTexture(
			LPDIRECT3DTEXTURE9        pTexture,
			LPD3DXFILL2D              pFunction,
			LPVOID                    pData);

		HRESULT WINAPI
			D3DXFillCubeTexture(
			LPDIRECT3DCUBETEXTURE9    pCubeTexture,
			LPD3DXFILL3D              pFunction,
			LPVOID                    pData);

		HRESULT WINAPI
			D3DXFillVolumeTexture(
			LPDIRECT3DVOLUMETEXTURE9  pVolumeTexture,
			LPD3DXFILL3D              pFunction,
			LPVOID                    pData);

		HRESULT WINAPI 
			D3DXFillTextureTX(
			LPDIRECT3DTEXTURE9        pTexture,
			LPD3DXTEXTURESHADER       pTextureShader);


		HRESULT WINAPI
			D3DXFillCubeTextureTX(
			LPDIRECT3DCUBETEXTURE9    pCubeTexture,
			LPD3DXTEXTURESHADER       pTextureShader);


		HRESULT WINAPI 
			D3DXFillVolumeTextureTX(
			LPDIRECT3DVOLUMETEXTURE9  pVolumeTexture,
			LPD3DXTEXTURESHADER       pTextureShader);

		HRESULT WINAPI
			D3DXComputeNormalMap(
			LPDIRECT3DTEXTURE9        pTexture,
			LPDIRECT3DTEXTURE9        pSrcTexture,
			CONST PALETTEENTRY*       pSrcPalette,
			DWORD                     Flags,
			DWORD                     Channel,
			FLOAT                     Amplitude);

		//@}

	} // namespace dx9

} // namespace xeres
